package com.luluteam.pushlib;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.luluteam.pushlib.model.TagParams;
import com.luluteam.pushlib.model.TargetParams;

import java.util.List;

public class NewsActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_news);
        TagParams tagParams = getIntent().getParcelableExtra(TagParams.INTENT_TAG_PARAMS);
        String messageId = tagParams.getMessageId();
        System.out.println("getIntent==messageId==" + messageId);
        List<TargetParams> params = tagParams.getTargetParams();
        String url = "www.baidu.com";
        for (TargetParams targetParams : params) {
            if (targetParams.getKey().equals("url")) {
                url = targetParams.getValue();
            }

        }

        WebView webView = findViewById(R.id.webview);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        webView.getSettings().setSupportMultipleWindows(true);
        webView.setWebViewClient(new WebViewClient());
        webView.setWebChromeClient(new WebChromeClient());

        webView.loadUrl(url);

    }
}
